home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Program Name: Stiletto */
- /* */
- /* File Name: CAWindow.c */
- /* */
- /* © Apple Computer, Inc. 1991-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1991-07-05 Chris Halim Original version */
- /* 1995-06-26 Jaakko Railo Version 2.0 */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "Resources.h"
- #include "ToolUtils.h"
-
- #ifndef __TELEPHONES__
- #include "Telephones.h"
- #endif
-
- #include "CAHandlers.h"
- #include "CAWindow.h"
- #include "Constants.h"
- #include "DNHandlers.h"
- #include "DNWindow.h"
- #include "LogWindow.h"
- #include "TermWindow.h"
- #include "Utilities.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- enum {
- kBlindTransfer = 0,
- kConsultTransfer= 1
- };
-
- /****************************************** PROTOTYPES ******************************************/
-
- void AttachCAWindowControls (CAWindowPtr caWindow, TELCAHandle caHand);
-
- Boolean DoCAWindowMouseDown (const EventRecord *theEvent);
- void DoCAWindowClick (WindowPtr theWindow, const EventRecord * theEvent);
- void DoCAWindowActivate (WindowPtr theWindow, Boolean becomingActive);
- void DoCAWindowUpdate (WindowPtr theWindow);
- void DoCAWindowOSEvent (const EventRecord *theEvent);
- void DoCAWindowSuspend (Boolean doClipConvert);
- void DoCAWindowResume (Boolean doClipConvert);
-
- void HandleAnswer (CAWindowPtr caWindow);
- void HandleDeflect (CAWindowPtr caWindow);
- void HandleReject (CAWindowPtr caWindow);
- void HandleDrop (CAWindowPtr caWindow);
- void HandleConf (CAWindowPtr caWindow);
- void HandleConfSplit (CAWindowPtr caWindow);
- void HandleTransfer (CAWindowPtr caWindow);
- void HandlePark (CAWindowPtr caWindow);
- void HandleCallBack (CAWindowPtr caWindow);
- void HandleDial (CAWindowPtr caWindow);
- void HandleHold (CAWindowPtr caWindow, short * value);
-
- void HandleBlindTransfer (CAWindowPtr caWindow);
- void HandleConsultTransfer (CAWindowPtr caWindow);
-
- void PrepareDeflectDLOGUserItems (DialogPtr theDialog);
- short DisplayDeflectDialog (CAWindowPtr caWindow);
- void PutDeflectAttribToDialog (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib);
- void PutDialogSetupToDeflectAttrib (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib);
-
- void PrepareTransferDLOGUserItems (DialogPtr theDialog);
- short DisplayTransferDialog (CAWindowPtr caWindow);
- void PutTransferAttribToDialog (DialogPtr theDialog, TransferAttribHandle theTransferAttrib);
- void PutDialogSetupToTransferAttrib (DialogPtr theDialog, TransferAttribHandle theTransferAttrib);
-
- void PrepareParkCallDLOGUserItems (DialogPtr theDialog);
- short DisplayParkCallDialog (Str255 parkDN);
-
- void PrepareGetDigitsDLOGUserItems (DialogPtr theDialog);
- short DisplayGetDigitsDialog (Str255 digits);
-
- void PrepareGetUserUserInfoDLOGUserItems (DialogPtr theDialog);
- short GetUserUserInfo (Str255 userUserInfo);
-
- void PrepareGetReasonDLOGUserItems (DialogPtr theDialog);
- short GetReason (short * number);
-
- void HandleTransferWithCA (CAWindowPtr caWindow);
- void HandleConferenceWithCA (CAWindowPtr caWindow);
-
- void PrepareGetCAListDLOGUserItems (DialogPtr theDialog, CAWindowPtr caWindow);
- short DisplayGetCAListDialog (TELCAHandle *caHand, CAWindowPtr caWindow);
- void BuildCAListMenu (MenuHandle theMenu, CAWindowPtr caWindow);
-
- /******************************************** GLOBALS *******************************************/
-
- extern LogWindowPtr gLogWindow;
- extern TelWindowPtr gTelWindow;
-
- extern ModalFilterUPP gStandardFilterUPP;
- extern UserItemUPP gDrawBoxUPP;
- extern UserItemUPP gDrawDefaultUPP;
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- #pragma segment CAWindow
- Boolean IsHandledByCAWindowList (CAWindowPtr caWindowList, const EventRecord * theEvent)
- {
- Boolean wasHandled = false;
- CAWindowPtr tCAWindow = caWindowList;
-
- while (tCAWindow && !(wasHandled = IsHandledByCAWindow (tCAWindow, theEvent))) {
- tCAWindow = tCAWindow->next;
- }
-
- return (wasHandled);
- }
-
-
- #pragma segment CAWindow
- Boolean IsHandledByCAWindow (CAWindowPtr caWindow, const EventRecord * theEvent)
- {
- WindowPtr theWindow;
- Boolean wasHandled = false;
- char key;
-
- if (caWindow != nil) {
- switch ( theEvent->what ) {
- case mouseDown:
- (void) FindWindow(theEvent->where, &theWindow);
- if (theWindow == (WindowPtr) caWindow) {
- wasHandled = DoCAWindowMouseDown (theEvent);
- }
- break;
-
- case activateEvt:
- if ((CAWindowPtr) theEvent->message == caWindow) {
- DoCAWindowActivate ((WindowPtr) caWindow, (theEvent->modifiers & activeFlag) != 0);
- wasHandled = true;
- }
- break;
-
- case updateEvt:
- if ((CAWindowPtr) theEvent->message == caWindow) {
- DoCAWindowUpdate ((WindowPtr) caWindow);
- wasHandled = true;
- }
- break;
-
- case osEvt:
- if ((CAWindowPtr) FrontWindow () == caWindow) {
- DoCAWindowOSEvent (theEvent);
- wasHandled = false;
- }
- break;
-
- case keyDown:
- case autoKey:
- if ((CAWindowPtr) FrontWindow() == caWindow) {
- key = theEvent->message & charCodeMask;
- if ( theEvent->modifiers & cmdKey ) { // Command key is down
- wasHandled = false;
- } else {
- switch (key) {
- case 't' :
- case 'T' :
- HandleTransferWithCA (caWindow);
- wasHandled = true;
- break;
-
- case 'c' :
- case 'C' :
- HandleConferenceWithCA (caWindow);
- wasHandled = true;
- break;
-
- case 'f' :
- case 'F' :
- DumpCAFlags (caWindow->fCAHandle);
- break;
-
- case 'i' :
- case 'I' :
- DumpCAInfo (caWindow->fCAHandle);
- break;
-
- case 's' :
- case 'S' :
- DumpCAState (caWindow->fCAHandle);
- break;
-
- case 'e' :
- case 'E' :
- DumpCAEvents ((*caWindow->fCAHandle)->hTELDN);
- break;
-
- default :
- wasHandled = false;
- }
- }
- }
- break;
-
- default :
- wasHandled = false;
- }
- }
-
- return (wasHandled);
- }
-
-
- #pragma segment CAWindow
- Boolean DoCAWindowMouseDown (const EventRecord *theEvent)
- {
- short part;
- WindowPtr theWindow;
- Boolean wasHandled = false;
-
- part = FindWindow(theEvent->where, &theWindow);
- switch ( part ) {
- case inContent:
- if ( theWindow != FrontWindow() ) {
- SelectWindow(theWindow);
- } else
- DoCAWindowClick (theWindow, theEvent);
-
- wasHandled = true;
- break;
-
- default :
- wasHandled = false;
- }
-
- return (wasHandled);
- }
-
-
- #pragma segment CAWindow
- void DoCAWindowClick (WindowPtr theWindow, const EventRecord * theEvent)
- {
- Point mousePos;
- WindowPtr savedPort;
- short part, value;
- ControlHandle theControl;
-
- GetPort (&savedPort);
- SetPort (theWindow);
-
- mousePos = theEvent->where;
- GlobalToLocal (&mousePos);
-
- part = FindControl (mousePos, theWindow, &theControl);
- switch (part) {
- case 0 : // invisible or inactive control was clicked
- break;
-
- case inThumb :
- break;
-
- case inButton :
- part = TrackControl (theControl, mousePos, nil);
- if (part != 0) {
- switch (GetCRefCon (theControl)) {
- case rAnswerCNTL :
- HandleAnswer ((CAWindowPtr) theWindow);
- break;
- case rDeflectCNTL :
- HandleDeflect ((CAWindowPtr) theWindow);
- break;
- case rRejectCNTL :
- HandleReject ((CAWindowPtr) theWindow);
- break;
- case rDropCNTL :
- HandleDrop ((CAWindowPtr) theWindow);
- break;
- case rConfCNTL :
- HandleConferenceWithCA ((CAWindowPtr) theWindow);
- break;
- case rConfSplitCNTL :
- HandleConfSplit ((CAWindowPtr) theWindow);
- break;
- case rTransferCNTL :
- HandleTransferWithCA ((CAWindowPtr) theWindow);
- break;
- case rTransfer2CNTL :
- HandleBlindTransfer ((CAWindowPtr) theWindow);
- break;
- case rParkCNTL :
- HandlePark ((CAWindowPtr) theWindow);
- break;
- case rCallBackCNTL :
- HandleCallBack ((CAWindowPtr) theWindow);
- break;
- case rDialCNTL :
- HandleDial ((CAWindowPtr) theWindow);
- break;
- }
- }
- break;
-
- case inCheckBox:
- part = TrackControl (theControl, mousePos, nil);
- if (part != 0) {
- value = (GetCtlValue (theControl)) ? false : true;
-
- switch (GetCRefCon (theControl)) {
- case rHoldCNTL :
- HandleHold ((CAWindowPtr) theWindow, &value);
- break;
- }
-
- // SetCtlValue (theControl, value);
- }
- break;
- }
-
- SetPort (savedPort);
- }
-
-
- #pragma segment CAWindow
- void DoCAWindowActivate (WindowPtr theWindow, Boolean becomingActive)
- {
- WindowPtr savedPort;
- ControlHandle theControl;
-
- GetPort (&savedPort);
- SetPort (theWindow);
-
- theControl = ((WindowPeek) theWindow)->controlList;
- while (theControl != nil) {
- HiliteControl (theControl, (becomingActive)? 0 : 0xFF);
- theControl = (*theControl)->nextControl;
- }
-
- SetPort (savedPort);
- }
-
-
- #pragma segment CAWindow
- void DoCAWindowUpdate (WindowPtr theWindow)
- {
- WindowPtr savedPort;
-
- BeginUpdate (theWindow);
- if ( ! EmptyRgn (theWindow->visRgn) )
- {
- GetPort (&savedPort);
- SetPort (theWindow);
-
- // EraseRect(&theWindow->portRect);
- UpdtControl (theWindow, theWindow->visRgn);
-
- SetPort (savedPort);
- }
- EndUpdate (theWindow);
- }
-
-
- #pragma segment CAWindow
- void DoCAWindowOSEvent (const EventRecord *theEvent)
- {
- Boolean doConvert;
- unsigned char evType;
-
- evType = (unsigned char) (theEvent->message >> 24) & 0x00ff; // Get the high byte.
- switch (evType) { // The high byte of message is the type of event.
- case suspendResumeMessage :
- doConvert = (theEvent->message & convertClipboardFlag) != 0;
-
- if ((theEvent->message & resumeFlag) == 0)
- DoCAWindowSuspend (doConvert);
-
- else DoCAWindowResume (doConvert);
- break;
- }
- }
-
-
- #pragma segment CAWindow
- void DoCAWindowSuspend (Boolean doClipConvert)
- {
- #pragma unused (doClipConvert)
-
- DoCAWindowActivate (FrontWindow(), false);
- }
-
-
- #pragma segment CAWindow
- void DoCAWindowResume (Boolean doClipConvert)
- {
- #pragma unused (doClipConvert)
-
- InitCursor ();
- DoCAWindowActivate (FrontWindow(), true);
- }
-
-
- #pragma segment CAWindow
- CAWindowPtr CreateCAWindow (TELCAHandle caHand, char * title)
- {
- CAWindowPtr caWindow;
- WindowPtr savedPort;
- Ptr tPtr;
-
- tPtr = NewPtrClear (sizeof (CAWindowRec));
- if (tPtr == nil) {
- AlertUser ("\pNot enough memory to create ca window !", MemError ());
- return (nil);
- }
-
- if (HasColorQD())
- caWindow = (CAWindowPtr) GetNewCWindow (rCAWIND, tPtr, (WindowPtr)(-1L));
- else
- caWindow = (CAWindowPtr) GetNewWindow (rCAWIND, tPtr, (WindowPtr)(-1L));
-
- if (caWindow == nil) {
- AlertUser ("\pUnable to get a WIND resource for ca window!", ResError ());
- DisposPtr (tPtr);
- return (nil);
- }
-
- caWindow->fDeflectAttrib = (DeflectAttribHandle) NewHandleClear (sizeof(DeflectAttrib));
- if (caWindow->fDeflectAttrib == nil) {
- AlertUser ("\pNot enough memory to create ca window !", MemError ());
- DisposeWindow ((WindowPtr) caWindow);
- return (nil);
- }
-
- caWindow->fTransferAttrib = (TransferAttribHandle) NewHandleClear (sizeof(TransferAttrib));
- if (caWindow->fTransferAttrib == nil) {
- AlertUser ("\pNot enough memory to create ca window !", MemError ());
- DisposeWindow ((WindowPtr) caWindow);
- return (nil);
- }
-
- /**
- ** Set the window's characteristics.
- **
- **/
-
- GetPort (&savedPort);
- SetPort ((WindowPtr) caWindow);
- TextSize (9);
- SetPort (savedPort);
-
- setwtitle ((WindowPtr) caWindow, title);
-
- AttachCAWindowControls (caWindow, caHand);
-
- caWindow->fCAHandle = caHand;
- caWindow->fConfInitiated = false;
- caWindow->fTransferInitiated = false;
-
- (*caHand)->userData = (long) caWindow; // so we can find the corresponding cawindow if given a caHand
-
- ShowWindow ((WindowPtr) caWindow);
-
- return (caWindow);
- }
-
-
- #pragma segment CAWindow
- void DisposeCAWindow (CAWindowPtr caWindow)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
-
- if (caWindow != nil) {
-
- if (caWindow->fDeflectAttrib)
- DisposHandle ((Handle) caWindow->fDeflectAttrib);
-
- if (caWindow->fTransferAttrib)
- DisposHandle ((Handle) caWindow->fTransferAttrib);
-
- if (caHand) {
- if ((errCode = TELCADispose (caHand)) != noErr)
- PutCLine (gLogWindow, kErrorColor, "### TELCADispose failed : %d", errCode);
- }
-
- DisposeWindow ((WindowPtr) caWindow);
- }
- }
-
-
- #pragma segment CAWindow
- void AttachCAWindowControls (CAWindowPtr caWindow, TELCAHandle caHand)
- {
- OSErr errCode;
- WindowPtr savedPort;
- ControlHandle theControl;
- long caFeatureFlags, caOtherFeatures;
-
- GetPort (&savedPort);
- SetPort ((WindowPtr) caWindow);
-
- caWindow->fAnswer = GetNewControl (rAnswerCNTL, (WindowPtr) caWindow);
- caWindow->fDeflect = GetNewControl (rDeflectCNTL, (WindowPtr) caWindow);
- caWindow->fReject = GetNewControl (rRejectCNTL, (WindowPtr) caWindow);
- caWindow->fDrop = GetNewControl (rDropCNTL, (WindowPtr) caWindow);
- caWindow->fConf = GetNewControl (rConfCNTL, (WindowPtr) caWindow);
- caWindow->fConf2 = GetNewControl (rConfSplitCNTL, (WindowPtr) caWindow);
- caWindow->fTransfer = GetNewControl (rTransferCNTL, (WindowPtr) caWindow);
- caWindow->fTransfer2 = GetNewControl (rTransfer2CNTL, (WindowPtr) caWindow);
- caWindow->fPark = GetNewControl (rParkCNTL, (WindowPtr) caWindow);
- caWindow->fCallBack = GetNewControl (rCallBackCNTL, (WindowPtr) caWindow);
- caWindow->fDial = GetNewControl (rDialCNTL, (WindowPtr) caWindow);
-
- caWindow->fHold = GetNewControl (rHoldCNTL, (WindowPtr) caWindow);
-
- if ((errCode = TELGetCAFlags (caHand, &caFeatureFlags, &caOtherFeatures)) != noErr)
- ; // PutCLine (gLogWindow, kErrorColor, "### TELGetCAFlags fails : %d", errCode);
-
- SetCtlValue (caWindow->fHold, (caFeatureFlags & holdActive));
-
- theControl = ((WindowPeek) caWindow)->controlList;
- while (theControl != nil) {
- HiliteControl (theControl, 0xFF);
- theControl = (*theControl)->nextControl;
- }
-
- SetPort (savedPort);
- }
-
-
- #pragma segment CAWindow
- void HandleAnswer (CAWindowPtr caWindow)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
-
- if (caHand) {
- if ((errCode = TELAnswerCall (caHand)) == noErr)
- PutLine (gLogWindow, "TELAnswerCall (%08x)", caHand);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELAnswerCall fails : %d", errCode);
- }
- }
-
-
- #pragma segment CAWindow
- void HandleDeflect (CAWindowPtr caWindow)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
- DeflectAttribHandle tDeflectAttrib = caWindow->fDeflectAttrib;
-
- if (caHand) {
- if (DisplayDeflectDialog (caWindow) == ok) {
- errCode = TELDeflectCall (caHand,
- (*tDeflectAttrib)->destDN,
- (*tDeflectAttrib)->destName,
- (*tDeflectAttrib)->subAddr);
- if (errCode == noErr)
- PutLine (gLogWindow, "TELDeflectCall (%08x)", caHand);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELDeflectCall fails : %d", errCode);
- }
- }
- }
-
-
- #pragma segment CAWindow
- void HandleReject (CAWindowPtr caWindow)
- {
- OSErr errCode;
- short reason;
- TELCAHandle caHand = caWindow->fCAHandle;
-
- if (caHand) {
- if (GetReason (&reason) == ok)
- {
- if ((errCode = TELRejectCall (caHand, reason)) == noErr)
- PutLine (gLogWindow, "TELRejectCall (%08x)", caHand);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELRejectCall fails : %d", errCode);
- }
- }
- }
-
-
- #pragma segment CAWindow
- void HandleDrop (CAWindowPtr caWindow)
- {
- OSErr errCode;
- Str255 userUserInfo;
- TELCAHandle caHand = caWindow->fCAHandle;
- TELHandle termHand = (*caHand)->hTEL;
-
- if (caHand) {
- if ((errCode = TELGetInfo (termHand)) == noErr) {
- if ((*(**termHand).pTELTerm).featureFlags & hasUserUserInfo)
- GetUserUserInfo (userUserInfo);
- } else
- PutCLine (gLogWindow, kErrorColor, "### TELGetInfo fails : %d", errCode);
-
- if ((errCode = TELDrop (caHand, userUserInfo)) == noErr)
- PutLine (gLogWindow, "TELDrop (%08x)", caHand);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELDrop fails : %d", errCode);
- }
- }
-
-
- #pragma segment CAWindow
- void HandleConf (CAWindowPtr caWindow1)
- {
- OSErr errCode = noErr;
- TELCAHandle caHand1 = caWindow1->fCAHandle, caHand2;
- long caFeatureFlags, caOtherFeatures;
- CAWindowPtr caWindow2;
-
- if (caHand1) {
- if (caWindow1->fConfInitiated == false) {
- if ((errCode = TELGetCAFlags (caHand1, &caFeatureFlags, &caOtherFeatures)) == noErr) {
- if ((caHand2 = SetUpACall ((DNWindowPtr) (*caHand1)->refCon)) != nil) {
- errCode = TELConferencePrep (caHand1, caHand2, (*caHand1)->conferenceLimit);
- if (errCode == noErr) {
- PutLine (gLogWindow, "TELConferencePrep (%08x,%08x), ConfLimit = %d", caHand1, caHand2, (*caHand1)->conferenceLimit);
-
- caWindow2 = (CAWindowPtr) (*caHand2)->userData;
- caWindow2->fConfInitiated = true;
- SetCTitle (caWindow2->fConf, "\pConf Est");
-
- // errCode = TELCAMsgHand ((*caHand2)->hTELDN, telAllCAMsgs, CAConfMsgHandler, SetCurrentA5());
- // if (errCode != noErr)
- // PutCLine (gLogWindow, kErrorColor, "### TELCAMsgHand fails : %d", errCode);
- }
- else {
- PutCLine (gLogWindow, kErrorColor, "### TELConferencePrep fails : %d", errCode);
-
- RemoveFromCAList ((DNWindowPtr) (*caHand1)->refCon, caHand2);
- }
- }
- }
- else
- PutCLine (gLogWindow, kErrorColor, "### TELGetCAFlags fails : %d", errCode);
- }
- else {
- if ((errCode = TELConferenceEstablish ((*caHand1)->relatedCA, caHand1)) == noErr)
- PutLine (gLogWindow, "TELConferenceEstablish (%08x,%08x)", (*caHand1)->relatedCA, caHand1);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELConferenceEstablish fails : %d", errCode);
-
- caWindow1->fConfInitiated = false;
- SetCTitle (caWindow1->fConf, "\pConference");
- }
- }
- }
-
-
- #pragma segment CAWindow
- void HandleConfSplit (CAWindowPtr caWindow)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
-
- if (caHand) {
- if ((errCode = TELConferenceSplit (caHand)) == noErr)
- PutLine (gLogWindow, "TELConferenceSplit (%08x)", caHand);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELConferenceSplit fails : %d", errCode);
- }
- }
-
-
- #pragma segment CAWindow
- void HandleBlindTransfer (CAWindowPtr caWindow)
- {
- TransferAttribHandle tTransferAttrib = caWindow->fTransferAttrib;
- TELCAHandle caHand = caWindow->fCAHandle;
- OSErr errCode;
-
- if (DisplayTransferDialog (caWindow) == ok) {
- errCode = TELTransferBlind (caHand, (*tTransferAttrib)->destDN,
- (*tTransferAttrib)->destName,
- (*tTransferAttrib)->subAddr);
- if (errCode == noErr)
- PutLine (gLogWindow, "TELTransferBlind (%08x)", caHand);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELTransferBlind fails : %d", errCode);
- }
- }
-
-
- #pragma segment CAWindow
- void HandleConsultTransfer (CAWindowPtr caWindow1)
- {
- TELCAHandle caHand1 = caWindow1->fCAHandle, caHand2;
- OSErr errCode;
- CAWindowPtr caWindow2;
-
- if (caWindow1->fTransferInitiated == false) {
- if ((caHand2 = SetUpACall ((DNWindowPtr) (*caHand1)->refCon)) != nil) {
- if ((errCode = TELTransferPrep (caHand1, caHand2)) == noErr) {
- PutLine (gLogWindow, "TELTransferPrep (%08x,%08x)", caHand1, caHand2);
-
- caWindow2 = (CAWindowPtr) (*caHand2)->userData;
- caWindow2->fTransferInitiated = true;
- SetCTitle (caWindow2->fTransfer, "\pTransfer Est");
- }
- else {
- PutCLine (gLogWindow, kErrorColor, "### TELTransferPrep fails : %d", errCode);
- RemoveFromCAList ((DNWindowPtr) (*caHand1)->refCon, caHand2);
- }
- }
- }
- else {
- if ((errCode = TELTransferEstablish ((*caHand1)->relatedCA, caHand1)) == noErr)
- PutLine (gLogWindow, "TELTransferEstablish (%08x,%08x)", (*caHand1)->relatedCA, caHand1);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELTransferEstablish fails : %d", errCode);
-
- caWindow1->fTransferInitiated = false;
- SetCTitle (caWindow1->fTransfer, "\pTransfer");
- }
- }
-
-
- #pragma segment CAWindow
- void HandleTransfer (CAWindowPtr caWindow)
- {
- #pragma unused (caWindow)
- }
-
-
- #pragma segment CAWindow
- void HandlePark (CAWindowPtr caWindow)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
- Str255 parkDN;
- StringPtr parkID = nil;
- long caFeatureFlags, caOtherFeatures;
-
- if (caHand) {
- if ((errCode = TELGetCAFlags (caHand, &caFeatureFlags, &caOtherFeatures)) == noErr) {
-
- if (caOtherFeatures & parkWithGivenID) {
- if (DisplayParkCallDialog (parkDN) == ok) {
- errCode = TELParkCall (caHand, &parkID, parkDN);
- if (errCode == noErr)
- PutLine (gLogWindow, "TELParkCall (%08x) parkDN = %s parkID = %s", caHand,
- parkDN, parkID);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELParkCall fails : %d", errCode);
-
- if (parkID != nil)
- DisposPtr ((Ptr) parkID);
- }
- }
- else
- {
- errCode = TELParkCall (caHand, &parkID, "\p");
- if (errCode == noErr)
- PutLine (gLogWindow, "TELParkCall (%08x) parkID = %s", caHand, parkID);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELParkCall fails : %d", errCode);
-
- if (parkID != nil)
- DisposPtr ((Ptr) parkID);
- }
- }
- else
- PutCLine (gLogWindow, kErrorColor, "### TELGetCAFlags fails : %d", errCode);
- }
- }
-
-
- #pragma segment CAWindow
- void HandleCallBack (CAWindowPtr caWindow)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
- short cbRef = 0;
-
- if (caHand) {
- if ((errCode = TELCallbackSet (caHand, &cbRef)) == noErr){
- PutLine (gLogWindow, "TELCallbackSet (%08x) -> cbRef = %d", caHand, cbRef);
- }
- else {
- PutCLine (gLogWindow, kErrorColor, "### TELCallbackSet fails : %d", errCode);
- }
- }
- }
-
-
- #pragma segment CAWindow
- void HandleDial (CAWindowPtr caWindow)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
- Str255 digits;
-
- if (caHand) {
- if (DisplayGetDigitsDialog (digits) == ok) {
- if ((errCode = TELDialDigits (caHand, digits)) == noErr){
- PutLine (gLogWindow, "TELDialDigits (%08x)", caHand);
- }
- else {
- PutCLine (gLogWindow, kErrorColor, "### TELDialDigits fails : %d", errCode);
- }
- }
- }
- }
-
-
- #pragma segment CAWindow
- void HandleHold (CAWindowPtr caWindow, short * value)
- {
- OSErr errCode;
- TELCAHandle caHand = caWindow->fCAHandle;
-
- if (caHand) {
- if (*value) {
- if ((errCode = TELHold (caHand)) == noErr){
- PutLine (gLogWindow, "TELHold (%08x)", caHand);
- *value = true;
- }
- else {
- PutCLine (gLogWindow, kErrorColor, "### TELHold fails : %d", errCode);
- *value = false;
- }
- }
- else {
- if ((errCode = TELRetrieve (caHand)) == noErr){
- PutLine (gLogWindow, "TELRetrieve (%08x)", caHand);
- *value = false;
- }
- else {
- PutCLine (gLogWindow, kErrorColor, "### TELRetrieve fails : %d", errCode);
- *value = true;
- }
- }
- }
- }
-
-
- #pragma segment CAWindow
- void PrepareDeflectDLOGUserItems (DialogPtr theDialog)
- {
- short itemType;
- Handle item;
- Rect box;
- CursHandle watch = GetCursor(watchCursor);
-
- if (watch != nil)
- SetCursor (*watch);
-
- GetDItem (theDialog, kDeflectBox1, &itemType, &item, &box);
- SetDItem (theDialog, kDeflectBox1, itemType, (Handle) gDrawBoxUPP, &box);
-
- GetDItem (theDialog, kDeflectDefault, &itemType, &item, &box);
- SetDItem (theDialog, kDeflectDefault, itemType, (Handle) gDrawDefaultUPP, &box);
-
- if (watch != nil)
- ReleaseResource ((Handle) watch);
-
- SetCursor (&qd.arrow);
- }
-
-
- #pragma segment CAWindow
- short DisplayDeflectDialog (CAWindowPtr caWindow)
- {
- DialogPtr theDialog;
- short itemHit;
- short returnValue;
- DeflectAttribHandle theDeflectAttrib = caWindow->fDeflectAttrib;
-
- theDialog = GetNewDialog (rDeflectDLOG, nil, (WindowPtr)(-1L));
- if (theDialog == nil) {
- AlertUser ("\pUnable to get a DLOG resource !", ResError());
- return (-1);
- }
-
- PrepareDeflectDLOGUserItems (theDialog);
- PutDeflectAttribToDialog (theDialog, theDeflectAttrib);
-
- ShowWindow (theDialog);
-
- ModalDialog (gStandardFilterUPP, &itemHit);
-
- HideWindow (theDialog);
-
- switch (itemHit) {
- case ok :
- PutDialogSetupToDeflectAttrib (theDialog, theDeflectAttrib);
- returnValue = ok;
-
- break;
-
- default :
- returnValue = cancel;
- }
-
- DisposDialog (theDialog);
-
- return (returnValue);
- }
-
-
- #pragma segment CAWindow
- void PutDeflectAttribToDialog (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
-
- GetDItem (theDialog, kDeflectNumber, &itemKind, &itemHand, &itemRect);
- SetIText (itemHand, (*theDeflectAttrib)->destDN);
- SelIText (theDialog, kDeflectNumber, 0, 32767);
-
- GetDItem (theDialog, kDeflectSubAddr, &itemKind, &itemHand, &itemRect);
- SetIText (itemHand, (*theDeflectAttrib)->subAddr);
- }
-
-
- #pragma segment CAWindow
- void PutDialogSetupToDeflectAttrib (DialogPtr theDialog, DeflectAttribHandle theDeflectAttrib)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
-
- GetDItem (theDialog, kDeflectNumber, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, (*theDeflectAttrib)->destDN);
- GetDItem (theDialog, kDeflectSubAddr, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, (*theDeflectAttrib)->subAddr);
- }
-
-
- #pragma segment CAWindow
- void PrepareTransferDLOGUserItems (DialogPtr theDialog)
- {
- short itemType;
- Handle item;
- Rect box;
- CursHandle watch = GetCursor(watchCursor);
-
- if (watch != nil)
- SetCursor (*watch);
-
- GetDItem (theDialog, kTransferBox1, &itemType, &item, &box);
- SetDItem (theDialog, kTransferBox1, itemType, (Handle) gDrawBoxUPP, &box);
-
- GetDItem (theDialog, kTransferDefault, &itemType, &item, &box);
- SetDItem (theDialog, kTransferDefault, itemType, (Handle) gDrawDefaultUPP, &box);
-
- if (watch != nil)
- ReleaseResource ((Handle) watch);
-
- SetCursor (&qd.arrow);
- }
-
-
- #pragma segment CAWindow
- short DisplayTransferDialog (CAWindowPtr caWindow)
- {
- DialogPtr theDialog;
- short itemHit;
- short returnValue;
- TransferAttribHandle theTransferAttrib = caWindow->fTransferAttrib;
-
- theDialog = GetNewDialog (rTransferDLOG, nil, (WindowPtr)(-1L));
- if (theDialog == nil) {
- AlertUser ("\pUnable to get a DLOG resource !", ResError());
- return (-1);
- }
-
- PrepareTransferDLOGUserItems (theDialog);
- PutTransferAttribToDialog (theDialog, theTransferAttrib);
-
- ShowWindow (theDialog);
-
- ModalDialog (gStandardFilterUPP, &itemHit);
-
- HideWindow (theDialog);
-
- switch (itemHit) {
- case ok :
- PutDialogSetupToTransferAttrib (theDialog, theTransferAttrib);
- returnValue = ok;
-
- break;
-
- default :
- returnValue = cancel;
- }
-
- DisposDialog (theDialog);
-
- return (returnValue);
- }
-
-
- #pragma segment CAWindow
- void PutTransferAttribToDialog (DialogPtr theDialog, TransferAttribHandle theTransferAttrib)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
-
- GetDItem (theDialog, kTransferNumber, &itemKind, &itemHand, &itemRect);
- SetIText (itemHand, (*theTransferAttrib)->destDN);
- SelIText (theDialog, kTransferNumber, 0, 32767);
-
- GetDItem (theDialog, kTransferName, &itemKind, &itemHand, &itemRect);
- SetIText (itemHand, (*theTransferAttrib)->destName);
-
- GetDItem (theDialog, kTransferSubAddr, &itemKind, &itemHand, &itemRect);
- SetIText (itemHand, (*theTransferAttrib)->subAddr);
- }
-
-
- #pragma segment CAWindow
- void PutDialogSetupToTransferAttrib (DialogPtr theDialog, TransferAttribHandle theTransferAttrib)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
-
- GetDItem (theDialog, kTransferNumber, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, (*theTransferAttrib)->destDN);
- GetDItem (theDialog, kTransferName, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, (*theTransferAttrib)->destName);
- GetDItem (theDialog, kTransferSubAddr, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, (*theTransferAttrib)->subAddr);
- }
-
-
- #pragma segment CAWindow
- void PrepareParkCallDLOGUserItems (DialogPtr theDialog)
- {
- short itemType;
- Handle item;
- Rect box;
- CursHandle watch = GetCursor(watchCursor);
-
- if (watch != nil)
- SetCursor (*watch);
-
- GetDItem (theDialog, kParkCallBox1, &itemType, &item, &box);
- SetDItem (theDialog, kParkCallBox1, itemType, (Handle) gDrawBoxUPP, &box);
-
- GetDItem (theDialog, kParkCallDefault, &itemType, &item, &box);
- SetDItem (theDialog, kParkCallDefault, itemType, (Handle) gDrawDefaultUPP, &box);
-
- if (watch != nil)
- ReleaseResource ((Handle) watch);
-
- SetCursor (&qd.arrow);
- }
-
-
- #pragma segment CAWindow
- short DisplayParkCallDialog (Str255 parkDN)
- {
- DialogPtr theDialog;
- short itemHit;
- short returnValue;
- short itemKind;
- Handle itemHand;
- Rect itemRect;
-
- theDialog = GetNewDialog (rParkCallDLOG, nil, (WindowPtr)(-1L));
- if (theDialog == nil) {
- AlertUser ("\pUnable to get a DLOG resource !", ResError());
- return (-1);
- }
-
- PrepareParkCallDLOGUserItems (theDialog);
-
- ShowWindow (theDialog);
-
- ModalDialog (gStandardFilterUPP, &itemHit);
-
- HideWindow (theDialog);
-
- switch (itemHit) {
- case ok :
- GetDItem (theDialog, kParkCallNumber, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, parkDN);
- returnValue = ok;
- break;
-
- default :
- returnValue = cancel;
- }
-
- DisposDialog (theDialog);
-
- return (returnValue);
- }
-
-
- #pragma segment CAWindow
- void PrepareGetDigitsDLOGUserItems (DialogPtr theDialog)
- {
- short itemType;
- Handle item;
- Rect box;
- CursHandle watch = GetCursor(watchCursor);
-
- if (watch != nil)
- SetCursor (*watch);
-
- GetDItem (theDialog, kGetDigitsBox1, &itemType, &item, &box);
- SetDItem (theDialog, kGetDigitsBox1, itemType, (Handle) gDrawBoxUPP, &box);
-
- GetDItem (theDialog, kGetDigitsDefault, &itemType, &item, &box);
- SetDItem (theDialog, kGetDigitsDefault, itemType, (Handle) gDrawDefaultUPP, &box);
-
- if (watch != nil)
- ReleaseResource ((Handle) watch);
-
- SetCursor (&qd.arrow);
- }
-
-
- #pragma segment CAWindow
- short DisplayGetDigitsDialog (Str255 digits)
- {
- DialogPtr theDialog;
- short itemHit;
- short returnValue;
- short itemKind;
- Handle itemHand;
- Rect itemRect;
-
- theDialog = GetNewDialog (rGetDigitsDLOG, nil, (WindowPtr)(-1L));
- if (theDialog == nil) {
- AlertUser ("\pUnable to get a DLOG resource !", ResError());
- return (-1);
- }
-
- PrepareGetDigitsDLOGUserItems (theDialog);
-
- ShowWindow (theDialog);
-
- ModalDialog (gStandardFilterUPP, &itemHit);
-
- HideWindow (theDialog);
-
- switch (itemHit) {
- case ok :
- GetDItem (theDialog, kGetDigitsNumber, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, digits);
- returnValue = ok;
- break;
-
- default :
- returnValue = cancel;
- }
-
- DisposDialog (theDialog);
-
- return (returnValue);
- }
-
-
- #pragma segment CAWindow
- void PrepareGetUserUserInfoDLOGUserItems (DialogPtr theDialog)
- {
- short itemType;
- Handle item;
- Rect box;
- CursHandle watch = GetCursor(watchCursor);
-
- if (watch != nil)
- SetCursor (*watch);
-
- GetDItem (theDialog, kGetUserUserInfoBox1, &itemType, &item, &box);
- SetDItem (theDialog, kGetUserUserInfoBox1, itemType, (Handle) gDrawBoxUPP, &box);
-
- GetDItem (theDialog, kGetUserUserInfoDefault, &itemType, &item, &box);
- SetDItem (theDialog, kGetUserUserInfoDefault, itemType, (Handle) gDrawDefaultUPP, &box);
-
- if (watch != nil)
- ReleaseResource ((Handle) watch);
-
- SetCursor (&qd.arrow);
- }
-
-
- #pragma segment CAWindow
- short GetUserUserInfo (Str255 userUserInfo)
- {
- DialogPtr theDialog;
- short itemHit;
- short returnValue;
- short itemKind;
- Handle itemHand;
- Rect itemRect;
-
- theDialog = GetNewDialog (rGetUserUserInfoDLOG, nil, (WindowPtr)(-1L));
- if (theDialog == nil) {
- AlertUser ("\pUnable to get a DLOG resource !", ResError());
- return (-1);
- }
-
- PrepareGetUserUserInfoDLOGUserItems (theDialog);
-
- ShowWindow (theDialog);
-
- ModalDialog (gStandardFilterUPP, &itemHit);
-
- HideWindow (theDialog);
-
- switch (itemHit) {
- case ok :
- GetDItem (theDialog, kGetUserUserInfoNumber, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, userUserInfo);
- returnValue = ok;
- break;
-
- default :
- returnValue = cancel;
- }
-
- DisposDialog (theDialog);
-
- return (returnValue);
- }
-
-
- #pragma segment CAWindow
- void PrepareGetReasonDLOGUserItems (DialogPtr theDialog)
- {
- short itemType;
- Handle item;
- Rect box;
- CursHandle watch = GetCursor(watchCursor);
-
- if (watch != nil)
- SetCursor (*watch);
-
- GetDItem (theDialog, kGetReasonBox1, &itemType, &item, &box);
- SetDItem (theDialog, kGetReasonBox1, itemType, (Handle) gDrawBoxUPP, &box);
-
- GetDItem (theDialog, kGetReasonDefault, &itemType, &item, &box);
- SetDItem (theDialog, kGetReasonDefault, itemType, (Handle) gDrawDefaultUPP, &box);
-
- if (watch != nil)
- ReleaseResource ((Handle) watch);
-
- SetCursor (&qd.arrow);
- }
-
-
- #pragma segment CAWindow
- short GetReason (short * reason)
- {
- DialogPtr theDialog;
- short itemHit;
- short returnValue;
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- Str255 tStr;
- long tlong;
-
- theDialog = GetNewDialog (rGetReasonDLOG, nil, (WindowPtr)(-1L));
- if (theDialog == nil) {
- AlertUser ("\pUnable to get a DLOG resource !", ResError());
- return (-1);
- }
-
- PrepareGetReasonDLOGUserItems (theDialog);
-
- ShowWindow (theDialog);
-
- ModalDialog (gStandardFilterUPP, &itemHit);
-
- HideWindow (theDialog);
-
- switch (itemHit) {
- case ok :
- GetDItem (theDialog, kGetReasonNumber, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, tStr);
- StringToNum (tStr, &tlong);
- *reason = tlong;
- returnValue = ok;
- break;
-
- default :
- returnValue = cancel;
- }
-
- DisposDialog (theDialog);
-
- return (returnValue);
- }
-
-
- #pragma segment CAWindow
- void HandleTransferWithCA (CAWindowPtr caWindow)
- {
- TELCAHandle caHand1 = caWindow->fCAHandle, caHand2;
- OSErr errCode;
-
- if (! caWindow->fTransferInitiated) {
- switch (DisplayGetCAListDialog (&caHand2, caWindow)) {
- case ok :
- if ((errCode = TELTransferPrep (caHand1, caHand2)) == noErr) {
- PutLine (gLogWindow, "TELTransferPrep (%08x,%08x)", caHand1, caHand2);
-
- if ((errCode = TELTransferEstablish (caHand1, caHand2)) == noErr)
- PutLine (gLogWindow, "TELTransferEstablish (%08x,%08x)", caHand1, caHand2);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELTransferEstablish fails : %d", errCode);
- }
- else
- PutCLine (gLogWindow, kErrorColor, "### TELTransferPrep fails : %d", errCode);
- break;
-
- case kGetCAListNewCA :
- HandleConsultTransfer (caWindow);
- break;
- }
- }
- else
- HandleConsultTransfer (caWindow);
- }
-
-
- #pragma segment CAWindow
- void HandleConferenceWithCA (CAWindowPtr caWindow)
- {
- TELCAHandle caHand1 = caWindow->fCAHandle, caHand2;
- OSErr errCode;
-
- if (! caWindow->fConfInitiated) {
- switch (DisplayGetCAListDialog (&caHand2, caWindow)) {
- case ok :
- if ((errCode = TELConferencePrep (caHand1, caHand2, (*caHand1)->conferenceLimit)) == noErr) {
- PutLine (gLogWindow, "TELConferencePrep (%08x,%08x)", caHand1, caHand2);
-
- if ((errCode = TELConferenceEstablish (caHand1, caHand2)) == noErr)
- PutLine (gLogWindow, "TELConferenceEstablish (%08x,%08x)", caHand1, caHand2);
- else
- PutCLine (gLogWindow, kErrorColor, "### TELConferenceEstablish fails : %d", errCode);
- }
- else
- PutCLine (gLogWindow, kErrorColor, "### TELConferencePrep fails : %d", errCode);
- break;
-
- case kGetCAListNewCA :
- HandleConf (caWindow);
- break;
- }
- }
- else
- HandleConf (caWindow);
- }
-
-
- #pragma segment CAWindow
- void PrepareGetCAListDLOGUserItems (DialogPtr theDialog, CAWindowPtr caWindow)
- {
- short itemType;
- Handle item;
- Rect box;
- CursHandle watch = GetCursor(watchCursor);
-
- if (watch != nil)
- SetCursor (*watch);
-
- GetDItem (theDialog, kGetCAListBox1, &itemType, &item, &box);
- SetDItem (theDialog, kGetCAListBox1, itemType, (Handle) gDrawBoxUPP, &box);
-
- GetDItem (theDialog, kGetCAListDefault, &itemType, &item, &box);
- SetDItem (theDialog, kGetCAListDefault, itemType, (Handle) gDrawDefaultUPP, &box);
-
- BuildCAListMenu (GetPopupMHandle (theDialog, kGetCAListPopup), caWindow);
- SetPopupValue (theDialog, kGetCAListPopup, 1);
-
- if (watch != nil)
- ReleaseResource ((Handle) watch);
-
- SetCursor (&qd.arrow);
- }
-
-
- #pragma segment CAWindow
- short DisplayGetCAListDialog (TELCAHandle *caHand, CAWindowPtr caWindow)
- {
- DialogPtr theDialog;
- short itemHit;
- short returnValue;
-
- theDialog = GetNewDialog (rGetCAListDLOG, nil, (WindowPtr)(-1L));
- if (theDialog == nil) {
- AlertUser ("\pUnable to get a DLOG resource !", ResError());
- return (-1);
- }
-
- PrepareGetCAListDLOGUserItems (theDialog, caWindow);
-
- ShowWindow (theDialog);
-
- ModalDialog (gStandardFilterUPP, &itemHit);
-
- HideWindow (theDialog);
-
- switch (itemHit) {
- case ok :
- *caHand = GetNthCA (GetPopupValue (theDialog, kGetCAListPopup), GetDNWindow (caWindow->fCAHandle));
-
- if (*caHand)
- returnValue = ok;
- else
- returnValue = cancel;
- break;
-
- default :
- returnValue = itemHit;
- }
-
- DisposDialog (theDialog);
-
- return (returnValue);
- }
-
-
- #pragma segment CAWindow
- void BuildCAListMenu (MenuHandle theMenu, CAWindowPtr caWindow)
- {
- DNWindowPtr dnWindow;
- ListHandle theList;
- Str255 caString;
- TELCAHandle caHand = caWindow->fCAHandle;
- short length, item = 1;
- Cell tCell;
-
- if (caHand)
- {
- dnWindow = GetDNWindow (caHand);
- theList = dnWindow->fCAList;
- caWindow = dnWindow->fCAWindowList;
-
- SetPt (&tCell, 0, 0);
- while (caWindow) {
- length = 0xFF;
- LGetCell (caString+1, &length, tCell, theList);
- caString[0] = length;
-
- AppendMenu (theMenu, "\pX");
- SetItem (theMenu, item, caString);
-
- if (caHand == caWindow->fCAHandle)
- DisableItem (theMenu, item);
-
- caWindow = caWindow->next;
- ++item; ++tCell.v;
- }
- }
- }
-
-
-